package germmy.groovy;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class GermmyDemo {
 
    @Autowired
    private ScriptService scriptService;
 
    @Test
    public void run() {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    System.in));
            while (true) {
                // 循环获取输入，每次有输入即进行一次调用
                String line = reader.readLine();
                if ("exit".equals(line)) {
                    break;
                }
                scriptService.run();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}